

package com.zt.fbg.config;

import cn.hutool.crypto.SecureUtil;
import io.jsonwebtoken.JwtParser;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.impl.TextCodec;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.Base64Utils;


import java.security.PublicKey;

/**
 * Cors跨域
 *
 * @author carl
 * @since 1.0.0
 */
@Configuration
public class GatewayConfig {

    @Value("${publicKey}")
    private String publicKey;

    @Bean
    public JwtParser jwtParser(){

        //  PublicKey key = SecureUtil.generatePublicKey("RSA", Base64Utils.decode(publicKey.getBytes()));
        //  return Jwts.parser().setSigningKey(key);

        String encode = TextCodec.BASE64.encode(publicKey);
        return Jwts.parser().setSigningKey(encode);
    }
}
